#include "SetZigbeeParamCmd.h"

SetZigbeeParamCmd::SetZigbeeParamCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::ZigbeeConfigProtocol;
    this->m_functionCode = FunctionCode;
    this->m_isSucceed = false;
    this->m_type = 0;
    this->m_channel = 0;
    this->m_power = 0;
}

Package SetZigbeeParamCmd::toPackage()
{
    Package package;

    QByteArray body;

    body.append(m_type);
    body.append(m_channel);
    body.append(m_power);
    body.append(m_address);
    body.append(m_panId);
    body.append(m_extPanId);
    body.append(m_nwkKey);

    package.setFunction(SetZigbeeParamCmd::FunctionCode);
    package.setBody(body);

    return package;
}

void SetZigbeeParamCmd::unPackage(Package package)
{
    QByteArray body = package.body();

    m_isSucceed = body.mid(0,1).toHex().toUInt(0,16);

}
bool SetZigbeeParamCmd::isSucceed() const
{
    return m_isSucceed;
}

void SetZigbeeParamCmd::setIsSucceed(bool isSucceed)
{
    m_isSucceed = isSucceed;
}
quint8 SetZigbeeParamCmd::type() const
{
    return m_type;
}

void SetZigbeeParamCmd::setType(const quint8 &type)
{
    m_type = type;
}
quint8 SetZigbeeParamCmd::channel() const
{
    return m_channel;
}

void SetZigbeeParamCmd::setChannel(const quint8 &channel)
{
    m_channel = channel;
}
quint8 SetZigbeeParamCmd::power() const
{
    return m_power;
}

void SetZigbeeParamCmd::setPower(const quint8 &power)
{
    m_power = power;
}
QByteArray SetZigbeeParamCmd::address() const
{
    return m_address;
}

void SetZigbeeParamCmd::setAddress(const QByteArray &address)
{
    m_address = address;
}
QByteArray SetZigbeeParamCmd::panId() const
{
    return m_panId;
}

void SetZigbeeParamCmd::setPanId(const QByteArray &panId)
{
    m_panId = panId;
}
QByteArray SetZigbeeParamCmd::extPanId() const
{
    return m_extPanId;
}

void SetZigbeeParamCmd::setExtPanId(const QByteArray &extPanId)
{
    m_extPanId = extPanId;
}
QByteArray SetZigbeeParamCmd::nwkKey() const
{
    return m_nwkKey;
}

void SetZigbeeParamCmd::setNwkKey(const QByteArray &nwkKey)
{
    m_nwkKey = nwkKey;
}
